<template>
  <div>
    <el-col>
      <el-scrollbar :height="forms + 'px'">
        <el-menu
          active-text-color="#ffd04b"
          background-color="#545c64"
          class="el-menu-vertical-demo"
          :default-active="$route.path || $route.meta.parent"
          text-color="#fff"
          :collapse="isCollapse"
          router
        >
          <el-menu-item index="/Index/home">
            <el-icon>
              <House />
            </el-icon>
            <span>首页</span>
          </el-menu-item>

          <el-sub-menu :index="item.path" v-for="item in page" :key="item.name">
            <template #title>
              <el-icon>
                <i :class="'iconfont ' + item.meta.icon"></i>
              </el-icon>
              <span>{{ item.meta.title }}</span>
            </template>
            <el-menu-item
              :index="'/Index/' + item.path + '/' + items.path"
              v-for="items in item.children"
              :key="items.name"
              v-show="!items.meta.hidden"
            >{{ items.meta.title }}</el-menu-item>
          </el-sub-menu>
        </el-menu>
      </el-scrollbar>
    </el-col>
  </div>
</template>

<script>
import { House } from "@element-plus/icons-vue";
import page from "@/router/page";
export default {
  props: ["isCollapse"],
  components: { House },
  data() {
    return {
      forms: window.innerHeight, //窗体高度
    };
  },
  methods: {
    // 挂载后
    mounted() {
      // 滚动条
      window.onresize = () => {
        this.forms = window.innerHeight;
      };
    },
  },
  setup() {
    return {
      House,
      page,
    };
  },
};
</script>


<style scoped lang="less">
.scrollbar-demo-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  margin: 10px;
  text-align: center;
  border-radius: 4px;
  background: var(--el-color-primary-light-9);
  color: var(--el-color-primary);
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
}
.el-menu {
  border: 0;
}
</style>